#include <iostream>
#include <fstream>
#include <string>
using namespace std;

/*The Purpose of this code is to load the tables into MySQL*/
/*There must be a locator file in the same folder named loc.txt*/

int main(int argc, char** argv)
{
    ifstream file;
    ifstream init;
    char c;
    string input,input2,input3;
    string header = "DB";
    file.open("loc.txt");
    while( !file.eof() )
    {
        //input = file.getline();
        getline(file,input);
        cout << "Input is " << input << endl;
        c = getchar();
        if(input[0] == '#')
        {
            goto skip;
        }
        if(header == input)
        {
            //do stuff
            while(input[0] != '@')
            {
                //input = file.getline();
                getline(file,input);
                cout << "File location passed is " << input << endl;
                c = getchar();
                if(input[0] == '@')
                {
                    goto skip;
                }
                cout << "File location passed is " << input << endl;
                c = getchar();
                //init.open(input.c_str());
                //while( !init.eof() )
                //{
                    //input = init.getline();
                    //getline(init,input2);
                    input2 = "mysql -p -u root";
                    cout << "Command passed to shell is " << input2 << endl;
                    input3 = input2 + " < " + input;
                    system(input3.c_str());
                    system("PAUSE");
                //}
            }
        }
        else
        {
            goto skip;
        }
skip:
        int holder = 0;
    }
    
    return 0;
}
